import { Component, OnInit, OnDestroy } from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router";
import {FetchService} from "../../module/fetch.service";
@Component({
    selector: 'center',
    templateUrl: 'center.component.html',
    styleUrls: ['center.component.scss'],
})
export class CenterComponent implements OnInit, OnDestroy {

    type;
    id;
    constructor(public router:Router, public route:ActivatedRoute,public fetch:FetchService) {
      console.log(this.route,11,'CenterComponent');
      route.params.subscribe(params=>{
          console.log(params,13,'CenterComponent');
          this.type = +params['type'];
      });

      route.firstChild && route.firstChild.params
          .subscribe(params=>{
              this.id = +params['id'];
          });
    }

    ngOnInit() {
        console.log(this.route,11,'CenterComponent-init');
        this.fetch.say();
    }

    changeItem(item) {
        this.router.navigate([item],{relativeTo:this.route});
    }

    ngOnDestroy() {

    }
}
